<template>
  <div v-if="loading" style="text-align: center;padding: 50px;">
    <a-spin></a-spin>
  </div>
  <entity-view
    v-else
    :model="beanInfo"
    @submit="submit"
    ref="form"
  >
    <div class="subtitle">基本信息</div>
    <div class="sub-content-flex">
      <a-form-item
        label="产品代码"
        :label-col="{ span: 10 }"
        :wrapper-col="{ span: 14 }"
        style="width: 50%"
        prop="baseProdCode"
      >
        <a-input v-model="beanInfo.baseProdCode" disabled  placeholder="请输入产品代码" disabled></a-input>
      </a-form-item>
      <a-form-item
        label="产品名称"
        :label-col="{ span: 10 }"
        :wrapper-col="{ span: 14 }"
        style="width: 50%"
        prop="baseProdName"
      >
        <a-input v-model="beanInfo.baseProdName" disabled  placeholder="请输入产品名称" disabled></a-input>
      </a-form-item>
      <a-form-item
        label="产品描述"
        :label-col="{ span: 10 }"
        :wrapper-col="{ span: 14 }"
        style="width: 50%"
        prop="baseProdDesc"
      >
        <a-input v-model="beanInfo.baseProdDesc" disabled  placeholder="请输入产品描述" disabled></a-input>
      </a-form-item>

      <a-form-item
        label="微信支付通道编码"
        prop="wechatChannelId"
        :label-col="{ span: 10 }"
        :wrapper-col="{ span: 14 }"
        style="width: 50%"
        v-if="beanInfo.baseProdCode=='02'||beanInfo.baseProdCode=='03'||beanInfo.baseProdCode=='07'"
      >
        <a-select
          placeholder="请选择微信支付通道编码"
          v-model="beanInfo.wechatChannelId"
          disabled
        >
          <template v-if="WXChannelList">
            <a-select-option
              v-for="i in WXChannelList"
              :key="i.id"
              :value="i.id"
            >{{ i.name }}
            </a-select-option>
          </template>
        </a-select>
      </a-form-item>
      <a-form-item
        label="支付宝支付通道编码"
        prop="alipayChannelId"
        :label-col="{ span: 10 }"
        :wrapper-col="{ span: 14 }"
        style="width: 50%"
        v-if="beanInfo.baseProdCode=='02'||beanInfo.baseProdCode=='03'||beanInfo.baseProdCode=='08'"
      >
        <a-select
          placeholder="请选择支付宝支付通道编码"
          v-model="beanInfo.alipayChannelId"
          disabled
        >
          <template v-if="ALChannelList">
            <a-select-option
              v-for="i in ALChannelList"
              :key="i.id"
              :value="i.id"
            >{{ i.name }}
            </a-select-option>
          </template>
        </a-select>
      </a-form-item>
    </div>
    <a-row v-if="beanInfo.baseProdCode !== '04'">
      <div class="subtitle">费率信息</div>
      <div class="sub-content-block">
        <a-table :columns="feeRateColumns" :dataSource="mchntFeeInfoList" rowKey="id" :pagination="false">
          <template slot="feeInputMode" slot-scope="text, record">
            <a-select v-model="record.feeInputMode" :disabled="optFlag!=='add'&&optFlag!=='upd'">
              <a-select-option value="1">手工输入按比率</a-select-option>
              <a-select-option value="2">手工输入按固定金额</a-select-option>
              <a-select-option value="3">手工输入按比率+封顶值</a-select-option>
            </a-select>
          </template>
          <template slot="feeRate" slot-scope="text, record">
            <a-input type="number" v-model="record.feeRate" :disabled="record.feeInputMode === '2'||(optFlag!=='add'&&optFlag!=='upd')" min="0"></a-input>
          </template>
          <template slot="feeCappingAmt" slot-scope="text, record">
            <a-input type="number" v-model="record.feeCappingAmt" disabled v-if="record.feeInputMode == '1'"></a-input>
            <a-input type="number" v-model="record.feeFixedAmt" :disabled="record.feeInputMode === '1'||(optFlag!=='add'&&optFlag!=='upd')" v-if="record.feeInputMode == '2'"></a-input>
            <a-input type="number" v-model="record.feeCappingAmt" :disabled="record.feeInputMode === '1'||(optFlag!=='add'&&optFlag!=='upd')" v-if="record.feeInputMode == '3'"></a-input>
          </template>
        </a-table>
      </div>
    </a-row>

    <div class="subtitle">交易权限信息</div>
    <div class="sub-content-block">
      <a-form-model-item label="交易大类" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
        <a-checkbox-group :options="txnGroup" v-model="selectedTxnGroup" @change="checkAllChange" :disabled="operatorType === 'view'"></a-checkbox-group>
      </a-form-model-item>
      <a-form-model-item
        :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }"
        :label="i.txnGroupName" v-for="i in txnGroup" :key="i.value"
        v-if="selectedTxnGroup.includes(i.txnGroup)">
        <a-checkbox-group
          class="check-box-group"
          v-model="i.selectedTxnGroup"
          :options="i.pTxnAuthMaps"
          :disabled="operatorType === 'view'"
          @change="checkboxChange($event, i)"
        ></a-checkbox-group>
      </a-form-model-item>
    </div>

    <a-row v-if="beanInfo.baseProdCode === '04'">
      <div class="subtitle">分期产品信息</div>
      <div class="sub-content-flex">
        <a-table
          ref="stageTableInfo"
          tableLayout="auto"
          :rowKey="
            (record, index) => {
              return index;
            }
          "
          :pagination="false"
          :columns="stageColumns"
          :dataSource="stageList"
        >
        </a-table>
      </div>
    </a-row>
  </entity-view>
</template>
<script>
  import EntityView from '../../../../components/common/entityView/EntityView'
  import FormItem from '../../../../components/common/entityView/FormItem'
  export default {
    name: "MchntProdDtl",

    components: {
      EntityView,
      FormItem,
    },
    inject: ['merchantProdInfoContext'],
    props: {
      visiable: {
        default: false,
      },
      layout: {
        type: String,
        default: 'horizontal'
      },
    },
    data() {
      return {
        loading: false,
        instId: "",
        mchntNo: "",
        beanInfo: {},
        prodInfoOrg: {},
        txnGroup: [],
        selectedTxnGroup: [], // 选中的交易权限组: [],
        operatorType: "view",
        optFlag: "view",
        flag: "",
        Status: "",
        WXChannelList: [],
        ALChannelList: [],
        feeTypeMap: [],
        mchntFeeInfoList: [],
        mchntAuthCtrlInfoList: [],
        feeTemplateList: [],
        feeRateColumns: [
          {
            title: '卡种/业务',
            dataIndex: 'feeTypeName'
          },
          {
            title: '费率输入方式',
            dataIndex: 'feeInputMode',
            scopedSlots: {customRender: 'feeInputMode'}
          },
          {
            title: '费率比率(‰)',
            dataIndex: 'feeRate',
            scopedSlots: {customRender: 'feeRate'}
          },
          {
            title: '封顶值(元)/固定金额(元)',
            dataIndex: 'feeCappingAmt',
            scopedSlots: {customRender: 'feeCappingAmt'}
          },
          {
            title: "费率生效日期",
            dataIndex: "feeEffectiveDate",
          },
          {
            title: "费率失效日期",
            dataIndex: "feeExpiryDate",
          }
        ],
        stageColumns: [
          {
            title: "分期产品代码",
            dataIndex: "prodStageCode",
          },
          {
            title: "分期产品名称",
            dataIndex: "prodStageName",
          },
          {
            title: "分期期数",
            dataIndex: "prodStageNum",
          },
        ],
        stageList: [],
        unitedFeeFlag:"",
      };
    },
    methods: {
      async getBeanInfo({...info},prodCode, instId, mchntNo, type,optFlag,{...prodUnitedFeeInfo},unitedFeeFlag) {
        this.instId = instId
        this.mchntNo = mchntNo
        this.beanInfo = info
        this.operatorType = type
        this.optFlag = optFlag
        this.prodCode = prodCode
        this.unitedFeeFlag=unitedFeeFlag;


        const param = {
          instId: instId,
          mchntNo: mchntNo,
          prodCode: this.prodCode,
          baseProdCode: info.baseProdCode,
          optFlag: optFlag
        }
        this.loading = true
        const res = await this.$get('/admin/mcmp/bMchntBaseInfo/editMchntProdDtl', param);
        this.loading = false
        if (res.status === 200) {
          this.txnGroup = (res.data.pTxnGroups || []).map(i => {
            i.label = i.txnGroupName;
            i.value = i.txnGroup
            if (i.isChecked === 'Y') {
              this.selectedTxnGroup = [...this.selectedTxnGroup, i.txnGroup]
            }
            if (i.pTxnAuthMaps) {
              i.selectedTxnGroup = []
              i.pTxnAuthMaps = i.pTxnAuthMaps.map(item => {
                item.label = item.txnName;
                item.value = item.txnNum.concat("|").concat(item.bizType)
                item.isChecked === 'Y' && i.selectedTxnGroup.push(item.value)
                return item
              })
              i.checkAll = i.selectedTxnGroup.length === i.pTxnAuthMaps.length
              i.indeterminate = !!i.selectedTxnGroup.length && i.selectedTxnGroup.length < i.pTxnAuthMaps.length
            }
            return i
          })
          this.feeTypeMap = res.data.feeTypeMap
          this.stageList = res.data.stageInfos
          this.mchntAuthCtrlInfoList = res.data.entity.mchntAuthCtrlInfoList
          res.data.entity.mchntFeeInfoList.forEach(item => {
            if(this.unitedFeeFlag==='Y'){

              item.feeInputMode=prodUnitedFeeInfo.feeInputMode;
              item.feeRate=prodUnitedFeeInfo.feeRate;
              item.feeCappingAmt=prodUnitedFeeInfo.feeCappingAmt;
            }
            item.feeTypeName = this.feeTypeMap[item.feeType]
            return item
          })
          this.mchntFeeInfoList = res.data.entity.mchntFeeInfoList
          if(this.beanInfo.baseProdCode=='02'||this.beanInfo.baseProdCode=='03'||this.beanInfo.baseProdCode=='07'){
            this.getWXChannel(res.data.wechatChannelId)

          }
          if(this.beanInfo.baseProdCode=='02'||this.beanInfo.baseProdCode=='03'||this.beanInfo.baseProdCode=='08'){
            this.getALChannel(res.data.alipayChannelId)
          }
          

          this.prodInfoOrg.mchntBaseProdList = [{
            mchntAuthCtrlInfoList: res.data.entity.mchntAuthCtrlInfoList,
            mchntStageInfoList: res.data.entity.mchntStageInfoList,
            mchntFeeInfoList: res.data.entity.mchntFeeInfoList
          }]
          this.flag = res.data.flag;
          this.Status = res.data.Status;
        }
      },


      async submit() {
        const res = await this.$refs.form.validate()
        if (res) {
          const map = {};
          this.txnGroup.map(item => {
            map[item.txnGroup] = item
          })
          const authCtrlList = []
          this.selectedTxnGroup.map(val => {
            const item = map[val];
            authCtrlList.push(...item.pTxnAuthMaps.filter(n => {
              if (item.selectedTxnGroup.indexOf(n.value) > -1) {
                n.instId = this.instId
                n.prodType = '00'
                n.baseProdCode = this.beanInfo.baseProdCode
                n.optFlag = this.optFlag
                n.supportFlag = "Y"
                return true
              }
            }))
          })
          const params = Object.assign({}, this.beanInfo, {
            instId: this.instId,
            optFlag: this.optFlag,
            mchntNo: this.mchntNo,
            prodCode: this.prodCode,
          })
          params.mchntBaseProdList = [{
            mchntAuthCtrlInfoList: authCtrlList,
            mchntStageInfoList: this.stageList,
            mchntFeeInfoList: this.mchntFeeInfoList
          }]
          
          this.compareRst(this.prodInfoOrg, params, this.optFlag);

          var oprType = this.flag;
          if (oprType == "add") {
            params.oprType = "01";
          } else if (oprType == "upd") {
            params.oprType = "02";
          }
          this.merchantProdInfoContext.dataSource.forEach((i, index) => {
            if (i.baseProdCode === params.baseProdCode) {
              i.baseProdPath='Y';
              this.merchantProdInfoContext.selectedRowKeys.push(index)
            }
          })
          this.merchantProdInfoContext.mchntProdDtlCfgList.push(params);

          this.$message.success("保存成功！");
          return true;

        }
      },
      async getWXChannel(val) {
        try {
          const res = await this.$get("/admin/igas/pDstChannelCfg/select2List", {
            q: encodeURIComponent(val+`&${this.instId}&UPWX`)
          });
          if (res.status === 200) {
            this.WXChannelList = res.data || {};
          }
        } catch (e) {
          console.error(e);
        }
      },
      async getALChannel(val) {
        try {
          const res = await this.$get("/admin/igas/pDstChannelCfg/select2List", {
            q: encodeURIComponent(val+`&${this.instId}&UPAL`)
          });
          if (res.status === 200) {
            this.ALChannelList = res.data || {};
          }
        } catch (e) {
          console.error(e);
        }
      },
      changeGroup(index){
        if(this.operatorType === 'view'){
          return false
        }
        this.pTxnGroups[index].isChecked === '1'?'0':'1'
      },
      changeAuthMaps(index,i){
        if(this.operatorType === 'view'){
          return false
        }
        this.pTxnGroups[index].pTxnAuthMaps.forEach((item,k) =>{
          if(i === k){
            item.isChecked === '1'?'0':'1'
          }
        })
      },

      async getFeeTemplateSelect2List (value = '') {
        this.feeTemplateList = []
        const res = await this.$get('/admin/mcmp/bMchntBaseInfo/feeTemplateSelect2List',{
          q: encodeURIComponent(value + '&' + this.merchantBaseInfoContext.query.instId)
        });
        this.feeTemplateList = res.data.results.map(i => {
          i.name = i.id + ' - ' + i.name
          i.value = i.id
          return i
        })
      },
      checkboxChange(e, item) {
        console.log(item);
        item.indeterminate = !!item.selectedTxnGroup.length && item.selectedTxnGroup.length < item.pTxnAuthMaps.length
        if (item.selectedTxnGroup.length === 0) {
          this.selectedTxnGroup.splice(this.selectedTxnGroup.indexOf(item.pTxnGroups), 1)
        }
      },
      checkAllChange() {
        this.txnGroup.map((item, index) => {
          item.indeterminate = false
          const checked = this.selectedTxnGroup.indexOf(item.value) > -1
          item.selectedTxnGroup = checked ? item.pTxnAuthMaps.map(i => i.txnNum.concat("|").concat(i.bizType)) : []
          this.$set(this.txnGroup, index, item)
        })
      },

      compareRst(prodInfoOrg,prodInfo,optFlag){

        var flag=this.flag;
        var Status=this.Status;

        if((optFlag=="upd"&&flag!="add")||(flag!="add"&&Status=="Y")) {
          
          var mchntBaseProdList = [];
          //比较获取新增的原子产品
          var mchntBaseProdListAdd = this.compareBaseProdInfo(prodInfoOrg, prodInfo, "01");
          //比较获取修改的原子产品,这个对象结构与新增、删除不一样，保存了新旧两个对象
          var mchntBaseProdListUpdObj = this.compareBaseProdInfo(prodInfoOrg, prodInfo, "02");
          var mchntBaseProdListUpd = [];
          //比较获取删除的原子产品
          var mchntBaseProdListDel = this.compareBaseProdInfo(prodInfo, prodInfoOrg, "04");
          //比较修改的原子产品

          mchntBaseProdListUpdObj.forEach((i, index) => {

            var baseProdInfo = mchntBaseProdListUpdObj[index].baseProdInfo;
            var baseProdInfoOrg = mchntBaseProdListUpdObj[index].baseProdInfoOrg;
            //权限只有新增和删除
            var prodAuthAdd = this.compareProdAuth(baseProdInfoOrg.mchntAuthCtrlInfoList, baseProdInfo.mchntAuthCtrlInfoList, "01");
            var prodAuthDel = this.compareProdAuth(baseProdInfo.mchntAuthCtrlInfoList, baseProdInfoOrg.mchntAuthCtrlInfoList, "04");
            //分期
            if (baseProdInfoOrg.mchntStageInfoList != undefined && baseProdInfo.mchntStageInfoList != undefined) {
              var prodStageUpd = this.compareProdStage(baseProdInfoOrg.mchntStageInfoList, baseProdInfo.mchntStageInfoList, "02");
            }
            // var prodStageAdd = compareProdStage(baseProdInfoOrg.mchntStageInfoList, baseProdInfo.mchntStageInfoList, "01");
            // var prodStageDel = compareProdStagedel(baseProdInfoOrg.mchntStageInfoList, baseProdInfo.mchntStageInfoList, "04");

            //对比费率
            if (baseProdInfoOrg.mchntFeeInfoList != undefined && baseProdInfo.mchntFeeInfoList != undefined) {
              var prodFeeUpd = this.compareProdFee(baseProdInfoOrg.mchntFeeInfoList, baseProdInfo.mchntFeeInfoList, "02");
              var prodFeeAdd = this.compareProdFee(baseProdInfoOrg.mchntFeeInfoList, baseProdInfo.mchntFeeInfoList, "01");
            }




            //费率
            var bProdFeeList = [];
            if (prodFeeUpd != undefined) {
              prodFeeUpd.forEach(function (e) {
                bProdFeeList.push(e);
              });
            }
            if (prodFeeAdd != undefined) {
              prodFeeAdd.forEach(function (e) {
                bProdFeeList.push(e);
              });
            }





            //分期
            var bProdStageList = [];
            if (prodStageUpd != undefined) {
              prodStageUpd.forEach(function (e) {
                bProdStageList.push(e);
              });
            }

            /*for(var b=0;b<prodStageAdd.length;b++){
                bProdStageList.push(prodStageAdd[b]);
            }*/

            /*for(var d=0;d<prodStageDel.length;d++){
                bProdStageList.push(prodStageDel[d]);
            }*/




            //权限
            var bProdAuthCtrlList = [];
            prodAuthAdd.forEach(function (e) {
              bProdAuthCtrlList.push(e);
            });
            prodAuthDel.forEach(function (e) {
              bProdAuthCtrlList.push(e);
            });


            baseProdInfo.mchntFeeInfoList = bProdFeeList;//费率
            baseProdInfo.mchntStageInfoList = bProdStageList;//分期
            baseProdInfo.mchntAuthCtrlInfoList = bProdAuthCtrlList;//业务权限
            mchntBaseProdListUpd.push(baseProdInfo);
          })

          prodInfo.mchntBaseProdList = mchntBaseProdListUpd;
        } else if (optFlag == "add" || flag == "add") {
          var mchntBaseProdListNew = [];
          prodInfo.mchntBaseProdList.forEach(function (e) {
            var baseProdInfo = e;
            baseProdInfo.oprType = "01";//新增

            //分期
            if (baseProdInfo.mchntStageInfoList !== undefined) {
              baseProdInfo.mchntStageInfoList.forEach(function (e) {
                e.oprType = "01";
              });
            }
            //费率
            if (baseProdInfo.mchntFeeInfoList !== undefined) {
              baseProdInfo.mchntFeeInfoList.forEach(function (e) {
                e.oprType = "01";
              });
            }
            //权限
            if (baseProdInfo.mchntAuthCtrlInfoList !== undefined) {
              baseProdInfo.mchntAuthCtrlInfoList.forEach(function (e) {
                e.oprType = "01";
              });
            }

            mchntBaseProdListNew.push(baseProdInfo);
          });

          prodInfo.mchntBaseProdList = mchntBaseProdListNew;
        }
      },

      /**
       * 比较分期信息 有新增、修改
       * @param prodStageOrgList
       * @param prodStageList
       * @param oprType
       * @returns {*}
       */
      compareProdStage(prodStageOrgList, prodStageList, oprType) {
        var baseProdStageList = [];
        for (var i = 0; i < prodStageList.length; i++) {
          var baseProdStage = prodStageList[i];
          var add = true;
          var baseProdStageOrg = {};
          for (var j = 0; j < prodStageOrgList.length; j++) {
            baseProdStageOrg = prodStageOrgList[j];
            if (baseProdStage.id == baseProdStageOrg.id) {
              if (oprType == "02") {
                if (baseProdStage.oprType == "upd") {
                  baseProdStage.oprType = "02";
                }
                var orgStr = JSON.stringify(baseProdStageOrg);
                var str = JSON.stringify(baseProdStage);
                if (str != orgStr) {
                  add = false;
                }
              }
            }
          }
          if (oprType == "02") {//修改，记录新旧两个对象
            if (!add) {
              baseProdStage.oprType = oprType;
              baseProdStageOrg.oprType = oprType;
              baseProdStageList.push(baseProdStage);
            }
          }
          /*if(oprType=="01"){
              if(baseProdStage.id=="undefined"){
                  baseProdStage.id="";
                  baseProdStage.oprType="01";
                  baseProdStageList.push(baseProdStage);
              }
          }*/
        }
        return baseProdStageList;

      },

      /**
       * 比较分期信息 删除
       * @param prodStageOrgList
       * @param prodStageList
       * @param oprType
       * @returns {*}
       */
      compareProdStagedel(prodStageOrgList, prodStageList, oprType) {
        var baseProdStageList = [];
        for (var i = 0; i < prodStageOrgList.length; i++) {
          var prodStageOrg = prodStageOrgList[i];
          var flag = 0;
          var prodStage = {};
          for (var j = 0; j < prodStageList.length; j++) {
            prodStage = prodStageList[j];
            if (prodStage.id != "") {
              if (prodStageOrg.id == prodStage.id) {
                flag = 0;
              } else {
                flag = 1;
              }
            }
          }
          if (flag > 0) {
            prodStageOrg.oprType = "04";
            baseProdStageList.push(prodStageOrg);
          }

        }
        return baseProdStageList;

      },


      /**
       * 比较权限 只有新增、删除
       * @param prodAuthOrgList
       * @param prodAuthList
       * @param oprType
       * @returns {*}
       */
      compareProdAuth(prodAuthOrgList, prodAuthList, oprType) {
        var baseProdAuthList = [];
        for (var i = 0; i < prodAuthList.length; i++) {
          var baseProdAuth = prodAuthList[i];
          var add = true;
          var baseProdAuthOrg = {};
          for (var j = 0; j < prodAuthOrgList.length; j++) {
            baseProdAuthOrg = prodAuthOrgList[j];
            if (baseProdAuth.baseProdCode == baseProdAuthOrg.baseProdCode
              && baseProdAuth.txnGroup == baseProdAuthOrg.txnGroup
              && baseProdAuth.txnNum == baseProdAuthOrg.txnNum
              && baseProdAuth.bizType == baseProdAuthOrg.bizType) {
              if (oprType == "02") {
                var orgStr = JSON.stringify(baseProdAuthOrg);
                var str = JSON.stringify(baseProdAuth);
                if (str != orgStr) {
                  add = false;
                }
              } else {
                add = false;
              }
            }
          }
          if (oprType == "02") {//修改，记录新旧两个对象
            if (!add) {
              baseProdAuth.oprType = oprType;
              baseProdAuthOrg.oprType = oprType;
              baseProdAuthList.push(baseProdAuth);
            }
          } else {//新增、删除
            if (add) {
              baseProdAuth.oprType = oprType;
              baseProdAuthList.push(baseProdAuth);
            }
          }
        }
        return baseProdAuthList;
      },

      /**
       * 比较费率 修改
       * @param prodFeeOrgList
       * @param prodFeeList
       * @param oprType
       * @returns {*}
       */
      compareProdFee(prodFeeOrgList, prodFeeList, oprType) {
        var baseProdFeeList = [];
        if (oprType != "01") {
          for (var i = 0; i < prodFeeList.length; i++) {
            var baseProdFee = prodFeeList[i];
            var add = true;
            var baseProdFeeOrg = {};
            for (var j = 0; j < prodFeeOrgList.length; j++) {
              baseProdFeeOrg = prodFeeOrgList[j];

              if (baseProdFee.id == baseProdFeeOrg.id) {
                var orgStr = JSON.stringify(baseProdFeeOrg);
                var str = JSON.stringify(baseProdFee);
                if (orgStr != str) {
                  baseProdFee.oprType = "02";
                  baseProdFeeList.push(baseProdFee);
                }
              }
            }
          }
        } else {
          for (var j = 0; j < prodFeeList.length; j++) {
            var baseProdFee = prodFeeList[i];
            var add = true;
            for (var i = 0; i < prodFeeOrgList.length; i++) {
              if (prodFeeList[j].feeType == prodFeeOrgList[i].feeType) {
                add = false;
              }
            }

            if (add) {
              baseProdFee.oprType = "01";
              baseProdFeeList.push(baseProdFee);
            }

          }
        }

        return baseProdFeeList;
      },

      /**
       * 比较原子产品 新增、修改、删除
       * @param prodInfoOrg
       * @param prodInfo
       * @param optType
       */
      compareBaseProdInfo(prodInfoOrg, prodInfo, oprType) {
        
        var baseProdList = [];
        for (var i = 0; i < prodInfo.mchntBaseProdList.length; i++) {
          var updateObj = {};
          var baseProdInfo = prodInfo.mchntBaseProdList[i];
          var add = true;
          var baseProdInfoOrg = {};
          for (var j = 0; j < prodInfoOrg.mchntBaseProdList.length; j++) {
            baseProdInfoOrg = prodInfoOrg.mchntBaseProdList[j];
            if (baseProdInfo.baseProdCode == baseProdInfoOrg.baseProdCode) {
              if (oprType == "02") {
                var orgStr = JSON.stringify(baseProdInfoOrg);
                var str = JSON.stringify(baseProdInfo);
                if (str != orgStr) {
                  add = false;
                }
              } else {
                add = false;
              }
            }
          }
          if (oprType == "02") {//修改，记录新旧两个对象
            if (!add) {
              baseProdInfo.oprType = oprType;
              baseProdInfoOrg.oprType = oprType;
              updateObj.baseProdInfoOrg = baseProdInfoOrg;
              updateObj.baseProdInfo = baseProdInfo;
              baseProdList.push(updateObj);
            }
          } else {//新增、删除
            if (add) {
              baseProdInfo.oprType = oprType;
              baseProdList.push(baseProdInfo);
            }
          }
        }
        return baseProdList;
      }
    },
  };
</script>
<style scoped>
  .btn-wrapper{
    padding: 0 10px;
    width: 100%;
    text-align: center;
  }
  .subtitle {
    width: 100%;
    font-size: 16px;
    margin-bottom: 10px;
    padding: 0 10px;
  }

  .sub-content-flex {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 10px;
    width: 100%;
  }

  .sub-content-block {
    display: block;
    flex-wrap: wrap;
    width: 100%;
    padding: 0 10px;
  }
  .ant-table-wrapper,.ant-row{
    width: 100%;
  }
  .ant-checkbox-wrapper{
    width: 33%;
    margin-left:0px
  }

</style>
